home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
devel
/
vbcc-wos-src
/
machines
/
amigawos
/
libsrc
/
stdio
/
_read.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-01
|
950b
|
56 lines
/*
** vbcc-PowerOpen/WarpOS Lowlevel read() function
**
** v0.2 29.10.98 phx
** disabled errno usage
** v0.1 31.07.98 phx
*/
#include <stdio.h>
#ifdef _ERRNO_
#include <errno.h>
#endif
#include <powerpc/powerpc.h>
#include <clib/powerpc_protos.h>
extern APTR DOSBase;
long _read(char *fh,void *buf,long size)
{
struct PPCArgs pa;
long n;
#ifdef _ERRNO_
if (!fh) {
errno = EBADF;
return (EOF);
}
if (size <= 0) {
errno = EINVAL;
return (EOF);
}
#endif
pa.PP_Code = DOSBase;
pa.PP_Offset = -42; /* _LVORead */
pa.PP_Flags = pa.PP_StackSize = 0;
pa.PP_Stack = NULL;
pa.PP_Regs[PPREG_D1] = (ULONG)fh;
pa.PP_Regs[PPREG_D2] = (ULONG)buf;
pa.PP_Regs[PPREG_D3] = (ULONG)size;
pa.PP_Regs[PPREG_A6] = (ULONG)DOSBase;
Run68K(&pa);
#ifdef _ERRNO_
if ((n = (long)pa.PP_Regs[PPREG_D0]) == -1) {
errno = EIO;
return (EOF);
}
return (n);
#else
return ((long)pa.PP_Regs[PPREG_D0]);
#endif
}